#include "Sql_list.h"

Elenemt_data Stu_data[50] =
    {
        {.name = "刘备", .sex = "男", .sco = 60, .age = 18, .id = 1},
        {.name = "关羽", .sex = "男", .sco = 60, .age = 18, .id = 2},
        {.name = "张飞", .sex = "女", .sco = 60, .age = 18, .id = 3},
        {.name = "诸葛", .sex = "男", .sco = 60, .age = 18, .id = 4},
        {.name = "赵云", .sex = "男", .sco = 60, .age = 18, .id = 5},
        {.name = "马超", .sex = "男", .sco = 60, .age = 18, .id = 6},
        {.name = "祝融", .sex = "女", .sco = 60, .age = 18, .id = 7},
        {.name = "小乔", .sex = "女", .sco = 60, .age = 18, .id = 8},
        {.name = "大乔", .sex = "女", .sco = 60, .age = 18, .id = 9},
        {.name = "貂蝉", .sex = "女", .sco = 60, .age = 18, .id = 10}};

void test(void)
{
    // 创建 表
    Sql_list S_guo;
    Sql_list *L = &S_guo;

    // 初始化
    Init_Sql_List(L);

    printf("\n\n=============== 插入 ===============\n\n");
    // 插入
    for (int i = 0; i < 10; i++)
    {
        tail_insert_list(L, Stu_data[i]);
    }

    // 打印
    // printf_Sql_List(L);

    // printf("\n\n=============== 删除 ===============\n\n");

    tail_del_list(L);

    // printf_Sql_List(L);
    // printf("\n\n=============== 删除 ===============\n\n");
    // 顺序表的判空：
    IsEmpty_Sql_List(L);
    // 顺序表的清空：
    // Clear_Sql_List(L);
    // IsEmpty_Sql_List(L);
    // printf("%d  \n", L->len);
    pos_insert_list(L, 3, Stu_data[9]);
    printf_Sql_List(L);
    printf("\n\n=============== 删除 ===============\n\n");
    pos_del_list(L, 3);
    printf_Sql_List(L);
    printf("\n\n=============== 删除 ===============\n\n");
    L = Merge_Sql_Lists(L, L);
    printf_Sql_List(L);
    // L = Expand_Sql_List(L , 30);
    // printf("%d  \n", L->len);
    printf("\n\n=============== 删除 ===============\n\n");
    printf("姓名:%s 性别:%s 年龄:%d 成绩:%d 学号:%d\n",
           find_by_index(L, 3).name, find_by_index(L, 3).sex, find_by_index(L, 3).age,
           find_by_index(L, 3).sco, find_by_index(L, 3).id);
}

int main(int argc, char const *argv[])
{
    test();
    return 0;
}
